package com.etc.service.impl;

import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.etc.dao.AttractionsMapper;
import com.etc.entity.Attractions;
import com.etc.service.AttractionsService;
import com.etc.util.PageData;


/**
 * cyf景点service实现层，已测试
 * @author Administrator
 *
 */

@Service(value = "attrationsService")
public class AttractionsServiceImpl implements AttractionsService {
	@Resource(name = "attrationsdao")
	private AttractionsMapper AttractionsMapper;

	@Override
	public boolean deleteByPrimaryKey(Integer attid) {

		return AttractionsMapper.deleteByPrimaryKey(attid) > 0;
	}

	@Override
	public boolean insert(Attractions Attractions) {

		return AttractionsMapper.insert(Attractions) > 0;
	}

	/**
	 * 根据传过来的字段是否为空，增加响应字段
	 */
	@Override
	public boolean insertSelective(Attractions Attractions) {

		return AttractionsMapper.insertSelective(Attractions) > 0;
	}
/**
 * 根据id查询景点
 */
	@Override
	public Attractions selectByPrimaryKey(Integer attid) {

		return AttractionsMapper.selectByPrimaryKey(attid);
	}
/**
 * 修改景点信息
 */
	@Override
	public boolean updateByPrimaryKeySelective(Attractions Attractions) {

		return AttractionsMapper.updateByPrimaryKeySelective(Attractions) > 0;
	}
	/**
	 * 修改景点信息
	 */
	@Override
	public boolean updateByPrimaryKey(Attractions Attractions) {

		return AttractionsMapper.updateByPrimaryKey(Attractions) > 0;
	}
/**
 * 查询所有
 */
	@Override
	public List<Attractions> selectAll() {
		List<Attractions> list = AttractionsMapper.selectAll();
		return list;
	}
/**
 * 分页+模糊查询
 */
	@Override
	public PageData<Attractions> selectByPage(int page, int limit, String context) {
		int start = (page - 1) * limit;
		if (context == null) {
			context = "";
		}
		int count = AttractionsMapper.selectCountByLike(context);
		List<Attractions> list = AttractionsMapper.selectByPage(start, limit, context);
		PageData<Attractions> data = new PageData<Attractions>(list, count, limit, page, context);
		data.setCode(0);
		data.setMsg("");
		return data;
	}

}
